![]() |
PATH![]() |
![]() ![]() |
A subroutine call for a subroutine with labeled parameters lists parameters other than the direct parameter in any order, using the labels in the subroutine definition to identify the parameter values.
subroutineName ¬
[ [ of | in ] directParameter ] ¬
[ [ subroutineParamLabel parameterValue ] ¬
| [ with labelForTrueParam [, labelForTrueParam ]... ¬
[ ( and | or | , ) labelForTrueParam ] ] ¬
| [ without labelForFalseParam [, labelForFalseParam ]...]¬
[ ( and | or | , ) labelForFalseParam ] ] ¬
| [ given label:parameterValue ¬
[, label:parameterValue ]...]...
subroutineName (an identifier) is the name of the subroutine.
directParameter is the direct parameter, if one is included in the subroutine definition. It can be any valid expression. As with application commands, the direct parameter must be first if it is included at all.
subroutineParamLabel is one of the following labels used in the definition of the subroutine: about , above , against , apart from, around , aside from , at , below , beneath , beside , between , by , for , from , instead of , into , on , onto , out of , over , since , thru (or through ), under .
parameterValue is the value of a parameter, which can be any valid expression.
labelForTrueParam is the label for a Boolean parameter whose value is true . You use this form in With clauses; because the value true is implied by the word With, you provide only the label, not the value. For an example of how to use a With clause, see the information on calling the subroutine findNumbers in Examples of Subroutines With Labeled Parameters. If you use or or a comma instead of and with the last parameter of a with clause, AppleScript changes the of or the comma to and during compilation.
labelForFalseParam is the label for a Boolean parameter whose value is false . You use this form in Without clauses; because the value false is implied by the word Without, you provide only the label, not the value. If you use or or a comma instead of and with the last parameter of a without clause, AppleScript changes the or or the comma to and during compilation.
label is any parameter label used in the definition of the subroutine that is not among the labels for subroutineParamLabel. You must use the special label given to specify these parameters. For an example, see Examples of Subroutines With Labeled Parameters.
If you use or or a comma instead of and with the last parameter of a with clause, AppleScript changes the or or the comma to and during compiling.
A subroutine call must include all the parameters specified in the subroutine definition. There is no way to specify optional parameters.
With the exception of the direct parameter, which must directly follow the subroutine name, labeled parameters can appear in any order. This includes parameters listed in Given, With, and Without clauses. Furthermore, you can include any number of Given, With, and Without clauses in a subroutine call. The examples for the findNumbers subroutine in Examples of Subroutines With Labeled Parameters demonstrate how a Given clause can be replaced by equivalent With and Without clauses.